﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace TimeQuest
{
    public static class Utils
    {
        public static bool HasCollided(Rectangle rectA, Rectangle rectB)
        {
            return (rectA.Right > rectB.Left && rectA.Left < rectB.Right &&
                rectA.Bottom > rectB.Top && rectA.Top < rectB.Bottom);
        }

        public static bool Overlapping(this Rectangle rectA, Rectangle rectB)
        {
            return (rectA.Right > rectB.Left && rectA.Left < rectB.Right &&
                rectA.Bottom > rectB.Top && rectA.Top < rectB.Bottom);
        }


        public static bool Within(this Rectangle rect, Point p)
        {
            return p.X > rect.X &&
                p.X < rect.X + rect.Width &&
                p.Y > rect.Y &&
                p.Y < rect.Y + rect.Height;
        }

        public static void Center(this XNAFormsLib.XNAForm form)
        {
            int w = MainGame.ScreenResolution.X;
            int h = MainGame.ScreenResolution.Y;

            form.Left = (w / 2) - (form.Width / 2);
            form.Top = (h / 2) - (form.Height / 2);
        }
    }
}